﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class admin_news_manage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //HiddenField_adminid.Value = useradminid.ToString();
            //HiddenField_userid.Value = userid.ToString();
            /*
            dyh_cms_newsTableAdapter ta = new dyh_cms_newsTableAdapter();
            DataSet_Zongpu_By_Dyh.dyh_cms_newsDataTable taDataTable = ta.Get_AllClassData_By_SubClassId_Or_MainClassId(userid, Convert.ToInt32(Request.QueryString["subclassid"].Trim()), Convert.ToInt32(Request.QueryString["classid"].Trim()), useradminid);
            GridView1.DataSource = taDataTable;
            GridView1.DataBind();
             * */
        }

        if (Session["shang_admin"] == null)
        {
            //Response.Redirect("get_your_passport.aspx");
        }
        /*
        quanxian_system_api quanxian = new quanxian_system_api();
        if (quanxian.check_page("news_manage.aspx", Session["pageset"].ToString()))
        {
            Response.Redirect("information.aspx?in=wrong&returnurl=news_manage.aspx");
        }

        news_system_api usernews = new news_system_api();

        if (usernews.usernews())
        {
            help.Visible = true;
        }
        else
        {
            help.Visible = false;
        }
         */

        Div1.Visible = false;

        if (Request.QueryString["bcn"] != "" && Request.QueryString["type"] == "count")
        {
            Div1.Visible = true;
            //shang_cms_news news = new shang_cms_news();
            //news_system_api action = new news_system_api();
            //action.get_class_all_hits(news);
            // int countall = news.hits;
            //news.bigclassname = Convert.ToInt32(Request.QueryString["bcn"]);
            //action.get_class_hits(news);
            //int countone = news.hits;
            //Label2.Text = countall.ToString();
            //Label3.Text = countone.ToString();
            //float persent = Convert.ToSingle(countone) / Convert.ToSingle(countall);
            //Label4.Text = persent.ToString();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == "")
        { Label1.Text = "搜索框文本不能为空"; }
        else
        {
            Response.Redirect("search.aspx?like=" + TextBox1.Text);
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == "")
        { Label1.Text = "搜索框文本不能为空"; }
        else
        {
            Response.Redirect("search.aspx?type=high&like=" + TextBox1.Text);
        }
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text == "")
        { Label1.Text = "搜索框文本不能为空"; }
        else
        {
            Response.Redirect("search.aspx?type=bh&like=" + TextBox1.Text);
        }
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        //help.Visible = false;
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        Div1.Visible = false;
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {


        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //显示新闻状态
            if (e.Row.Cells[6].Text == "1")
            {
                e.Row.Cells[6].Text = "草稿";
            }
            else if (e.Row.Cells[6].Text == "2")
            {
                e.Row.Cells[6].Text = "待审核";
            }
            else
            {
                e.Row.Cells[6].Text = "终审通过";
            }

            //显示新闻是否显示
            if (e.Row.Cells[7].Text == "False")
            {
                e.Row.Cells[7].Text = "启用";
            }
            else
            {
                e.Row.Cells[7].Text = "<font color='red'>禁用</font>";
            }


            //记录删除确认
            e.Row.Cells[9].Attributes.Add
               ("onclick", "javascript:return confirm('您确定要删除该记录吗?\\n\\n您将无法恢复！')");
            if ((Request.QueryString["id"] != null) && (e.Row.Cells[0].Text == Request.QueryString["id"].ToString().Trim()))
            {
                e.Row.Attributes.Add("style", "background-image: url('./images/outbanner.jpg'); background-repeat: repeat-x; background-position: center center; border: 1px solid #000000");
                //e.Row.Attributes.Add("id", "rensel");
            }
            else
            {
                e.Row.Attributes.Add("id", "ren");
            }

            //当鼠标停留时更改背景色
            //e.Row.Attributes.Add("id", "ren");
            e.Row.Attributes.Add("onclick", "this.id='out'");
        }
    }
    /*
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        Response.Write("<script language='Javascript'>confirm('你确实要删除吗?');</script>");

    }
     */
}
